/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('cloudcontrol', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CancelTaskResponseBody = {
  requestId?: string(name='requestId', example='473469C7-AA6F-4DC5-B3DB-A3DC0DE3****'),
}

model CancelTaskResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CancelTaskResponseBody(name='body'),
}

/**
 * @summary 取消任务
 *
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return CancelTaskResponse
 */
async function cancelTaskWithOptions(taskId: string, headers: map[string]string, runtime: Util.RuntimeOptions): CancelTaskResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'CancelTask',
    version = '2022-08-30',
    protocol = 'HTTPS',
    pathname = `/api/v1/tasks/${OpenApiUtil.getEncodeParam(taskId)}/operation/cancel`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 取消任务
 *
 * @return CancelTaskResponse
 */
async function cancelTask(taskId: string): CancelTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return cancelTaskWithOptions(taskId, headers, runtime);
}

model CreateResourceRequest {
  body?: map[string]any(name='body', example='{
     "AccountName": "cctest",
     "AccountPassword": "Aa1234****"
}'),
  clientToken?: string(name='clientToken', example='1e810dfe1468721d0664a49b9d9f74f4'),
  regionId?: string(name='regionId', example='cn-beijing'),
}

model CreateResourceResponseBody = {
  requestId?: string(name='requestId', example='473469C7-AA6F-4DC5-B3DB-A3DC0DE3****'),
  resourceId?: string(name='resourceId', example='cctest'),
  resourcePath?: string(name='resourcePath', example='Instance/r-8vbf5abe31c9c4d4/Account/cctest'),
  taskId?: string(name='taskId', example='task-433aead756057fff8189a7ce5****'),
}

model CreateResourceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateResourceResponseBody(name='body'),
}

/**
 * @summary 创建资源
 *
 * @param requestPath the whole path of resource string
 * @param request CreateResourceRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateResourceResponse
 */
async function createResourceWithOptions(requestPath: string, request: CreateResourceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateResourceResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.clientToken)) {
    query['clientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.regionId)) {
    query['regionId'] = request.regionId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(request.body),
  };
  var params = new OpenApi.Params{
    action = 'CreateResource',
    version = '2022-08-30',
    protocol = 'HTTPS',
    pathname = `${requestPath}`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 创建资源
 *
 * @param requestPath the whole path of resource string
 * @param request CreateResourceRequest
 * @return CreateResourceResponse
 */
async function createResource(requestPath: string, request: CreateResourceRequest): CreateResourceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createResourceWithOptions(requestPath, request, headers, runtime);
}

model DeleteResourceRequest {
  clientToken?: string(name='clientToken', example='1e810dfe1468721d0664a49b9d9f74f4'),
  regionId?: string(name='regionId', example='cn-beijing'),
}

model DeleteResourceResponseBody = {
  requestId?: string(name='requestId', example='473469C7-AA6F-4DC5-B3DB-A3DC0DE3****'),
  taskId?: string(name='taskId', example='task-433aead756057fff8189a7ce5****'),
}

model DeleteResourceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteResourceResponseBody(name='body'),
}

/**
 * @summary 删除资源
 *
 * @param requestPath the whole path of resource string
 * @param request DeleteResourceRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteResourceResponse
 */
async function deleteResourceWithOptions(requestPath: string, request: DeleteResourceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DeleteResourceResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.clientToken)) {
    query['clientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.regionId)) {
    query['regionId'] = request.regionId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteResource',
    version = '2022-08-30',
    protocol = 'HTTPS',
    pathname = `${requestPath}`,
    method = 'DELETE',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 删除资源
 *
 * @param requestPath the whole path of resource string
 * @param request DeleteResourceRequest
 * @return DeleteResourceResponse
 */
async function deleteResource(requestPath: string, request: DeleteResourceRequest): DeleteResourceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return deleteResourceWithOptions(requestPath, request, headers, runtime);
}

model GetPriceRequest {
  regionId?: string(name='regionId', example='cn-beijing'),
  resourceAttributes?: map[string]any(name='resourceAttributes', example='{
        "LoadBalancerName": "cc-test",
        "LoadBalancerSpec": "slb.s3.small",
        "InternetChargeType": "paybybandwidth",
        "AddressType": "internet",
        "PaymentType": "PayAsYouGo",
        "Bandwidth": 6
      }'),
}

model GetPriceShrinkRequest {
  regionId?: string(name='regionId', example='cn-beijing'),
  resourceAttributesShrink?: string(name='resourceAttributes', example='{
        "LoadBalancerName": "cc-test",
        "LoadBalancerSpec": "slb.s3.small",
        "InternetChargeType": "paybybandwidth",
        "AddressType": "internet",
        "PaymentType": "PayAsYouGo",
        "Bandwidth": 6
      }'),
}

model GetPriceResponseBody = {
  price?: {
    currency?: string(name='currency', example='CNY'),
    discountPrice?: float(name='discountPrice', example='0.0'),
    moduleDetails?: [ 
      {
        costAfterDiscount?: float(name='costAfterDiscount', example='0.02'),
        invoiceDiscount?: float(name='invoiceDiscount', example='0.0'),
        moduleCode?: string(name='moduleCode', example='InstanceRent'),
        moduleName?: string(name='moduleName', example='InstanceRent'),
        originalCost?: float(name='originalCost', example='1000.0'),
        priceType?: string(name='priceType', example='1.0'),
      }
    ](name='moduleDetails'),
    originalPrice?: float(name='originalPrice', example='760.0'),
    promotionDetails?: [ 
      {
        promotionDesc?: string(name='promotionDesc', example='37284'),
        promotionId?: long(name='promotionId'),
        promotionName?: string(name='promotionName'),
      }
    ](name='promotionDetails'),
    tradePrice?: float(name='tradePrice', example='0.0'),
  }(name='price'),
  requestId?: string(name='requestId', example='473469C7-AA6F-4DC5-B3DB-A3DC0DE3****'),
}

model GetPriceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetPriceResponseBody(name='body'),
}

/**
 * @summary 查询价格
 *
 * @param requestPath the whole path of resource string
 * @param tmpReq GetPriceRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetPriceResponse
 */
async function getPriceWithOptions(requestPath: string, tmpReq: GetPriceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetPriceResponse {
  Util.validateModel(tmpReq);
  var request = new GetPriceShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.resourceAttributes)) {
    request.resourceAttributesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.resourceAttributes, 'resourceAttributes', 'json');
  }
  var query : map[string]any = {};
  if (!Util.isUnset(request.regionId)) {
    query['regionId'] = request.regionId;
  }
  if (!Util.isUnset(request.resourceAttributesShrink)) {
    query['resourceAttributes'] = request.resourceAttributesShrink;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetPrice',
    version = '2022-08-30',
    protocol = 'HTTPS',
    pathname = `${requestPath}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 查询价格
 *
 * @param requestPath the whole path of resource string
 * @param request GetPriceRequest
 * @return GetPriceResponse
 */
async function getPrice(requestPath: string, request: GetPriceRequest): GetPriceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getPriceWithOptions(requestPath, request, headers, runtime);
}

model GetResourceTypeHeaders {
  commonHeaders?: map[string]string,
  xAcsAcceptLanguage?: string(name='x-acs-accept-language', example='zh_CH'),
}

model GetResourceTypeResponseBody = {
  requestId?: string(name='requestId', example='473469C7-AA6F-4DC5-B3DB-A3DC0DE3****'),
  resourceType?: {
    createOnlyProperties?: [ string ](name='createOnlyProperties'),
    deleteOnlyProperties?: [ string ](name='deleteOnlyProperties'),
    filterProperties?: [ string ](name='filterProperties'),
    getOnlyProperties?: [ string ](name='getOnlyProperties'),
    getResponseProperties?: [ string ](name='getResponseProperties'),
    handlers?: {
      create?: {
        permissions?: [ string ](name='permissions'),
      }(name='create'),
      delete?: {
        permissions?: [ string ](name='permissions'),
      }(name='delete'),
      get?: {
        permissions?: [ string ](name='permissions'),
      }(name='get'),
      list?: {
        permissions?: [ string ](name='permissions'),
      }(name='list'),
      update?: {
        permissions?: [ string ](name='permissions'),
      }(name='update'),
    }(name='handlers'),
    info?: {
      chargeType?: string(name='chargeType', example='paid'),
      deliveryScope?: string(name='deliveryScope', example='region'),
      description?: string(name='description', example='An ECS instance is equivalent to a virtual machine, including the most basic computing components such as CPU, memory, operating system, network, and disk. You can easily customize and change the configuration of the instance. You have full control over the virtual machine.'),
      title?: string(name='title', example='Instance'),
    }(name='info'),
    listOnlyProperties?: [ string ](name='listOnlyProperties'),
    listResponseProperties?: [ string ](name='listResponseProperties'),
    primaryIdentifier?: string(name='primaryIdentifier', example='/properties/InstanceId'),
    product?: string(name='product', example='ECS'),
    properties?: map[string]any(name='properties'),
    publicProperties?: [ string ](name='publicProperties'),
    readOnlyProperties?: [ string ](name='readOnlyProperties'),
    required?: [ string ](name='required'),
    resourceType?: string(name='resourceType', example='Instance'),
    sensitiveInfoProperties?: [ string ](name='sensitiveInfoProperties'),
    updateOnlyProperties?: [ string ](name='updateOnlyProperties'),
    updateTypeProperties?: [ string ](name='updateTypeProperties'),
  }(name='resourceType'),
}

model GetResourceTypeResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetResourceTypeResponseBody(name='body'),
}

/**
 * @summary 获取资源元数据
 *
 * @param requestPath the whole path of resource string
 * @param headers GetResourceTypeHeaders
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetResourceTypeResponse
 */
async function getResourceTypeWithOptions(requestPath: string, headers: GetResourceTypeHeaders, runtime: Util.RuntimeOptions): GetResourceTypeResponse {
  var realHeaders : map[string]string = {};
  if (!Util.isUnset(headers.commonHeaders)) {
    realHeaders = headers.commonHeaders;
  }
  if (!Util.isUnset(headers.xAcsAcceptLanguage)) {
    realHeaders['x-acs-accept-language'] = Util.toJSONString(headers.xAcsAcceptLanguage);
  }
  var req = new OpenApi.OpenApiRequest{ 
    headers = realHeaders,
  };
  var params = new OpenApi.Params{
    action = 'GetResourceType',
    version = '2022-08-30',
    protocol = 'HTTPS',
    pathname = `${requestPath}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 获取资源元数据
 *
 * @param requestPath the whole path of resource string
 * @return GetResourceTypeResponse
 */
async function getResourceType(requestPath: string): GetResourceTypeResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers = new GetResourceTypeHeaders{};
  return getResourceTypeWithOptions(requestPath, headers, runtime);
}

model GetResourcesRequest {
  filter?: map[string]any(name='filter'),
  maxResults?: int32(name='maxResults', example='10'),
  nextToken?: string(name='nextToken', example='AAAAAdDWBF2****'),
  regionId?: string(name='regionId', example='cn-beijing'),
}

model GetResourcesShrinkRequest {
  filterShrink?: string(name='filter'),
  maxResults?: int32(name='maxResults', example='10'),
  nextToken?: string(name='nextToken', example='AAAAAdDWBF2****'),
  regionId?: string(name='regionId', example='cn-beijing'),
}

model GetResourcesResponseBody = {
  maxResults?: int32(name='maxResults', example='10'),
  nextToken?: string(name='nextToken', example='AAAAAdDWBF2****'),
  requestId?: string(name='requestId', example='473469C7-AA6F-4DC5-B3DB-A3DC0DE3****'),
  resource?: {
    resourceAttributes?: map[string]any(name='resourceAttributes', example='{"Status":"Available","Description":"","AccountPrivilege":"RoleReadWrite","InstanceId":"r-8vbf5abe31c9c4d4","RegionId":"cn-zhangjiakou","AccountType":"Normal","TypeInfo":{},"AccountName":"cctest"}'),
    resourceId?: string(name='resourceId', example='cctest'),
  }(name='resource'),
  resources?: [ 
    {
      resourceAttributes?: map[string]any(name='resourceAttributes', example='{"Status":"Available","Description":"","AccountPrivilege":"RoleReadWrite","InstanceId":"r-8vbf5abe31c9c4d4","RegionId":"cn-zhangjiakou","AccountType":"Normal","TypeInfo":{},"AccountName":"cctest"}'),
      resourceId?: string(name='resourceId', example='cctest'),
    }
  ](name='resources'),
  totalCount?: int32(name='totalCount', example='20'),
}

model GetResourcesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetResourcesResponseBody(name='body'),
}

/**
 * @summary 查询资源
 *
 * @param requestPath the whole path of resource string
 * @param tmpReq GetResourcesRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetResourcesResponse
 */
async function getResourcesWithOptions(requestPath: string, tmpReq: GetResourcesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetResourcesResponse {
  Util.validateModel(tmpReq);
  var request = new GetResourcesShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.filter)) {
    request.filterShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.filter, 'filter', 'json');
  }
  var query : map[string]any = {};
  if (!Util.isUnset(request.filterShrink)) {
    query['filter'] = request.filterShrink;
  }
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.regionId)) {
    query['regionId'] = request.regionId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetResources',
    version = '2022-08-30',
    protocol = 'HTTPS',
    pathname = `${requestPath}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 查询资源
 *
 * @param requestPath the whole path of resource string
 * @param request GetResourcesRequest
 * @return GetResourcesResponse
 */
async function getResources(requestPath: string, request: GetResourcesRequest): GetResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getResourcesWithOptions(requestPath, request, headers, runtime);
}

model GetTaskResponseBody = {
  requestId?: string(name='requestId', example='473469C7-AA6F-4DC5-B3DB-A3DC0DE3****'),
  task?: {
    createTime?: string(name='createTime', example='2022-10-09T00:46:03Z'),
    error?: {
      code?: string(name='code', example='OperationFailure.OperationFailed'),
      message?: string(name='message', example='{
     "requestId": "123****",
     "errorCode": "InvalidRamUser.NoPermission",
     "errorMsg": "Ram user is not authorized to perform the operation."
}'),
    }(name='error'),
    product?: string(name='product', example='ECS'),
    regionId?: string(name='regionId', example='cn-beijing'),
    resourceId?: string(name='resourceId', example='i-8vbascjthm7kzhp3****'),
    resourcePath?: string(name='resourcePath', example='Instance/i-8vbascjthm7kzhp3****
Instance/r-8vbf5abe31c9c4d4/Account/cctest'),
    resourceType?: string(name='resourceType', example='Instance'),
    status?: string(name='status', example='Succeeded'),
    taskAction?: string(name='taskAction', example='Create'),
    taskId?: string(name='taskId', example='task-433aead756057fff8189a7ce5****'),
  }(name='task'),
}

model GetTaskResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetTaskResponseBody(name='body'),
}

/**
 * @summary 查询任务
 *
 * @description GET /api/v1/tasks/{taskId}。
 *
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetTaskResponse
 */
async function getTaskWithOptions(taskId: string, headers: map[string]string, runtime: Util.RuntimeOptions): GetTaskResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetTask',
    version = '2022-08-30',
    protocol = 'HTTPS',
    pathname = `/api/v1/tasks/${OpenApiUtil.getEncodeParam(taskId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 查询任务
 *
 * @description GET /api/v1/tasks/{taskId}。
 *
 * @return GetTaskResponse
 */
async function getTask(taskId: string): GetTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getTaskWithOptions(taskId, headers, runtime);
}

model ListDataSourcesRequest {
  attributeName?: string(name='attributeName', description='This parameter is required.', example='RegionId'),
  filter?: map[string]any(name='filter'),
}

model ListDataSourcesShrinkRequest {
  attributeName?: string(name='attributeName', description='This parameter is required.', example='RegionId'),
  filterShrink?: string(name='filter'),
}

model ListDataSourcesResponseBody = {
  dataSources?: [ 
    {
      id?: string(name='id', example='cn-beijing'),
    }
  ](name='dataSources'),
  requestId?: string(name='requestId', example='473469C7-AA6F-4DC5-B3DB-A3DC0DE3****'),
}

model ListDataSourcesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListDataSourcesResponseBody(name='body'),
}

/**
 * @summary 列举资源属性可选值
 *
 * @param requestPath the whole path of resource string
 * @param tmpReq ListDataSourcesRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListDataSourcesResponse
 */
async function listDataSourcesWithOptions(requestPath: string, tmpReq: ListDataSourcesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListDataSourcesResponse {
  Util.validateModel(tmpReq);
  var request = new ListDataSourcesShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.filter)) {
    request.filterShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.filter, 'filter', 'json');
  }
  var query : map[string]any = {};
  if (!Util.isUnset(request.attributeName)) {
    query['attributeName'] = request.attributeName;
  }
  if (!Util.isUnset(request.filterShrink)) {
    query['filter'] = request.filterShrink;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListDataSources',
    version = '2022-08-30',
    protocol = 'HTTPS',
    pathname = `${requestPath}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 列举资源属性可选值
 *
 * @param requestPath the whole path of resource string
 * @param request ListDataSourcesRequest
 * @return ListDataSourcesResponse
 */
async function listDataSources(requestPath: string, request: ListDataSourcesRequest): ListDataSourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listDataSourcesWithOptions(requestPath, request, headers, runtime);
}

model ListProductsHeaders {
  commonHeaders?: map[string]string,
  xAcsAcceptLanguage?: string(name='x-acs-accept-language', example='zh_CH'),
}

model ListProductsRequest {
  maxResults?: int32(name='maxResults', example='10'),
  nextToken?: string(name='nextToken', example='ECS'),
}

model ListProductsResponseBody = {
  maxResults?: int32(name='maxResults', example='10'),
  nextToken?: string(name='nextToken', example='Redis'),
  products?: [ 
    {
      productCode?: string(name='productCode', example='ECS'),
      productName?: string(name='productName', example='Elastic Compute Service'),
    }
  ](name='products'),
  requestId?: string(name='requestId', example='473469C7-AA6F-4DC5-B3DB-A3DC0DE3****'),
  totalCount?: int32(name='totalCount', example='20'),
}

model ListProductsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListProductsResponseBody(name='body'),
}

/**
 * @summary 列举资源类型
 *
 * @description GET /api/v1/providers/{provider}/products。
 *
 * @param request ListProductsRequest
 * @param headers ListProductsHeaders
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListProductsResponse
 */
async function listProductsWithOptions(provider: string, request: ListProductsRequest, headers: ListProductsHeaders, runtime: Util.RuntimeOptions): ListProductsResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }

  var realHeaders : map[string]string = {};
  if (!Util.isUnset(headers.commonHeaders)) {
    realHeaders = headers.commonHeaders;
  }
  if (!Util.isUnset(headers.xAcsAcceptLanguage)) {
    realHeaders['x-acs-accept-language'] = Util.toJSONString(headers.xAcsAcceptLanguage);
  }
  var req = new OpenApi.OpenApiRequest{ 
    headers = realHeaders,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListProducts',
    version = '2022-08-30',
    protocol = 'HTTPS',
    pathname = `/api/v1/providers/${OpenApiUtil.getEncodeParam(provider)}/products`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 列举资源类型
 *
 * @description GET /api/v1/providers/{provider}/products。
 *
 * @param request ListProductsRequest
 * @return ListProductsResponse
 */
async function listProducts(provider: string, request: ListProductsRequest): ListProductsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers = new ListProductsHeaders{};
  return listProductsWithOptions(provider, request, headers, runtime);
}

model ListResourceTypesHeaders {
  commonHeaders?: map[string]string,
  xAcsAcceptLanguage?: string(name='x-acs-accept-language', example='zh_CH'),
}

model ListResourceTypesRequest {
  maxResults?: int32(name='maxResults', example='10'),
  nextToken?: string(name='nextToken', example='ECS::Disk'),
  resourceTypes?: [ string ](name='resourceTypes'),
}

model ListResourceTypesShrinkRequest {
  maxResults?: int32(name='maxResults', example='10'),
  nextToken?: string(name='nextToken', example='ECS::Disk'),
  resourceTypesShrink?: string(name='resourceTypes'),
}

model ListResourceTypesResponseBody = {
  maxResults?: int32(name='maxResults', example='10'),
  nextToken?: string(name='nextToken', example='ECS::Disk'),
  requestId?: string(name='requestId', example='473469C7-AA6F-4DC5-B3DB-A3DC0DE3****'),
  resourceTypes?: [ 
    {
      createOnlyProperties?: [ string ](name='createOnlyProperties'),
      deleteOnlyProperties?: [ string ](name='deleteOnlyProperties'),
      filterProperties?: [ string ](name='filterProperties'),
      getOnlyProperties?: [ string ](name='getOnlyProperties'),
      getResponseProperties?: [ string ](name='getResponseProperties'),
      handlers?: {
        create?: {
          permissions?: [ string ](name='permissions'),
        }(name='create'),
        delete?: {
          permissions?: [ string ](name='permissions'),
        }(name='delete'),
        get?: {
          permissions?: [ string ](name='permissions'),
        }(name='get'),
        list?: {
          permissions?: [ string ](name='permissions'),
        }(name='list'),
        update?: {
          permissions?: [ string ](name='permissions'),
        }(name='update'),
      }(name='handlers'),
      info?: {
        chargeType?: string(name='chargeType', example='paid'),
        deliveryScope?: string(name='deliveryScope', example='region'),
        description?: string(name='description', example='An ECS instance is equivalent to a virtual machine, including the most basic computing components such as CPU, memory, operating system, network, and disk. You can easily customize and change the configuration of the instance. You have full control over the virtual machine.'),
        title?: string(name='title', example='Instance'),
      }(name='info'),
      listOnlyProperties?: [ string ](name='listOnlyProperties'),
      listResponseProperties?: [ string ](name='listResponseProperties'),
      primaryIdentifier?: string(name='primaryIdentifier', example='/properties/InstanceId'),
      product?: string(name='product', example='ECS'),
      properties?: map[string]any(name='properties'),
      publicProperties?: [ string ](name='publicProperties'),
      readOnlyProperties?: [ string ](name='readOnlyProperties'),
      required?: [ string ](name='required'),
      resourceType?: string(name='resourceType', example='Instance'),
      sensitiveInfoProperties?: [ string ](name='sensitiveInfoProperties'),
      updateOnlyProperties?: [ string ](name='updateOnlyProperties'),
      updateTypeProperties?: [ string ](name='updateTypeProperties'),
    }
  ](name='resourceTypes'),
  totalCount?: int32(name='totalCount', example='20'),
}

model ListResourceTypesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListResourceTypesResponseBody(name='body'),
}

/**
 * @summary 列举资源类型
 *
 * @description GET /api/v1/providers/{provider}/products/{product}/resourceTypes。
 *
 * @param tmpReq ListResourceTypesRequest
 * @param headers ListResourceTypesHeaders
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListResourceTypesResponse
 */
async function listResourceTypesWithOptions(provider: string, product: string, tmpReq: ListResourceTypesRequest, headers: ListResourceTypesHeaders, runtime: Util.RuntimeOptions): ListResourceTypesResponse {
  Util.validateModel(tmpReq);
  var request = new ListResourceTypesShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.resourceTypes)) {
    request.resourceTypesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.resourceTypes, 'resourceTypes', 'simple');
  }
  var query : map[string]any = {};
  if (!Util.isUnset(request.maxResults)) {
    query['maxResults'] = request.maxResults;
  }
  if (!Util.isUnset(request.nextToken)) {
    query['nextToken'] = request.nextToken;
  }
  if (!Util.isUnset(request.resourceTypesShrink)) {
    query['resourceTypes'] = request.resourceTypesShrink;
  }

  var realHeaders : map[string]string = {};
  if (!Util.isUnset(headers.commonHeaders)) {
    realHeaders = headers.commonHeaders;
  }
  if (!Util.isUnset(headers.xAcsAcceptLanguage)) {
    realHeaders['x-acs-accept-language'] = Util.toJSONString(headers.xAcsAcceptLanguage);
  }
  var req = new OpenApi.OpenApiRequest{ 
    headers = realHeaders,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListResourceTypes',
    version = '2022-08-30',
    protocol = 'HTTPS',
    pathname = `/api/v1/providers/${OpenApiUtil.getEncodeParam(provider)}/products/${OpenApiUtil.getEncodeParam(product)}/resourceTypes`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 列举资源类型
 *
 * @description GET /api/v1/providers/{provider}/products/{product}/resourceTypes。
 *
 * @param request ListResourceTypesRequest
 * @return ListResourceTypesResponse
 */
async function listResourceTypes(provider: string, product: string, request: ListResourceTypesRequest): ListResourceTypesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers = new ListResourceTypesHeaders{};
  return listResourceTypesWithOptions(provider, product, request, headers, runtime);
}

model UpdateResourceRequest {
  body?: map[string]any(name='body', example='{
     "AccountPassword": "4321****",
     "Description": "cctest"
}'),
  clientToken?: string(name='clientToken', example='1e810dfe1468721d0664a49b9d9f74f4'),
  regionId?: string(name='regionId', example='cn-beijing'),
}

model UpdateResourceResponseBody = {
  requestId?: string(name='requestId', example='473469C7-AA6F-4DC5-B3DB-A3DC0DE3****'),
  taskId?: string(name='taskId', example='task-433aead756057fff8189a7ce5****'),
}

model UpdateResourceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateResourceResponseBody(name='body'),
}

/**
 * @summary 更新资源
 *
 * @param requestPath the whole path of resource string
 * @param request UpdateResourceRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateResourceResponse
 */
async function updateResourceWithOptions(requestPath: string, request: UpdateResourceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): UpdateResourceResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.clientToken)) {
    query['clientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.regionId)) {
    query['regionId'] = request.regionId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(request.body),
  };
  var params = new OpenApi.Params{
    action = 'UpdateResource',
    version = '2022-08-30',
    protocol = 'HTTPS',
    pathname = `${requestPath}`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 更新资源
 *
 * @param requestPath the whole path of resource string
 * @param request UpdateResourceRequest
 * @return UpdateResourceResponse
 */
async function updateResource(requestPath: string, request: UpdateResourceRequest): UpdateResourceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return updateResourceWithOptions(requestPath, request, headers, runtime);
}

